package ch04;

/**
 * Created by 其 on 2016/3/20.
 */
import java.util.Scanner;

public class Search{
    public static void main(String[] args){
        int[] number = {1, 10, 31, 33, 37, 48, 60, 70, 80};
        Scanner scanner = new Scanner(System.in);
        int num = scanner.nextInt();
        System.out.println(binary(number,num));
    }
    public static int binary(int[] array, int value){
        int low = 0;
        int high = array.length - 1;
        int middle;
        while(low <= high){
            middle = (low + high) / 2;
            if(value == array[middle])
                return middle;
            if(value > array[middle])
                low = middle + 1;
            if(value < array[middle])
                high = middle - 1;
            //	System.out.println(middle);
        }
        return -1;
    }
}
